Skip to content

20260713-WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED-etc#10920

Merged
JacobBarthelmeh merged 18 commits into
wolfSSL:masterfrom
douzzer:20260713-WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED-etc
Jul 20, 2026
Merged

20260713-WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED-etc#10920
JacobBarthelmeh merged 18 commits into
wolfSSL:masterfrom
douzzer:20260713-WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED-etc

Conversation

@douzzer

@douzzer douzzer commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Implement FIPS shimming for wc_AesGcmEncrypt():

wolfssl/wolfcrypt/aes.h: if HAVE_FIPS && !WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED, make wc_AesGcmEncrypt() a WOLFSSL_LOCAL, and if !_WC_BUILDING_AES_C, add a WC_DEPRECATED() attribute to it.

wolfssl/wolfcrypt/wc_compat.h, wolfssl/wolfcrypt/include.am, .wolfssl_known_macro_extras: add wc_compat.h: when HAVE_FIPS and !WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED, shim wc_AesGcmEncrypt() to remap it to FIPS-allowed APIs.

wolfssl/wolfcrypt/types.h: at the end, #ifndef BUILDING_WOLFSSL, #include <wolfssl/wolfcrypt/wc_compat.h>, to assure transparent shimming of wc_AesGcmEncrypt() for all outside callers.

wolfcrypt/src/evp.c, wolfcrypt/src/hpke.c, wolfcrypt/src/pkcs7.c, wolfcrypt/benchmark/benchmark.c, wolfcrypt/test/test.c, wolfssl/ssl.h: #include <wolfssl/wolfcrypt/wc_compat.h> to shim in-library/in-module calls to wc_AesGcmEncrypt().

src/internal.c: in TicketEncDec(), add const attributes to constable input args, and fix swapped out/in in calls to wc_AesGcmEncrypt().

tests/api/test_aes.c: in test_wc_AesGcmEncryptDecrypt(), skip longIV test if WC_TEST_AES_GCM_ENCRYPT_NO_NONSTD_IV (defined by wc_compat.h when needed).

wolfssl/wolfcrypt/error-crypt.h, wolfssl/error-ssl.h, wolfcrypt/src/error.c, src/internal.c:

  • add FIPS_WRONG_API_E;
  • put several error codes back into sequence in wc_GetErrorString() switch().
  • move wc_static_assert()s from headers to corresponding .c files, to eliminate dependency on wolfcrypt/types.h;
  • remove unneeded #include <wolfssl/wolfcrypt/types.h> from error-crypt.h.

linuxkm/lkcapi_aes_glue.c: in the inner streaming loops for AES-GCM and AES-XTS (AesGcmCrypt_1(), km_AesXtsEncrypt(), and km_AesXtsDecrypt()), bypass FIPS wrappers to avoid frivolous overhead, with decisive check after looping by the Final function.

wolfcrypt/src/aes.c: revert atomic refactor of checkedAESNI, haveAESNI, and intel_flags (3f3ebca / #10871) to avoid frivolous atomic access overhead. Also use regular int, not cpuid_flags_atomic_t, for cpuid_flags in the WOLFSSL_ARMASM path, and similarly use a regular int for aes_ppc64_use_crypto in the WOLFSSL_PPC64_ASM_CRYPTO path.

wolfssl/wolfcrypt/wc_compat.h, wolfssl/wolfcrypt/fips_test.h, .wolfssl_known_macro_extras:

  • also inhibit recursive evaluation midway through random.h, fips.h, and fips_test.h (circular dependencies).
  • add WC_FIPS_ENUM_CAST_ID_DEFINED to allow detection of fips_test.h incomplete evaluation.

wolfcrypt/src/ed25519.c, tests/api/test_ed25519.c:

  • add missing null key checks to wc_ed25519_verify_msg_init(), wc_ed25519_verify_msg_update(), and wc_ed25519_verify_msg_final().
  • add WC_ARG_NOT_NULL() attributes to args of static functions as appropriate.
  • add FIPS >v6 gates to new null key tests and a new invalid hash size test in test_wc_ed25519_sign_verify_ctx_ph() and test_wc_ed25519_verify_streaming().

configure.ac: add --enable-all-quantum-crypto "Enable all quantum-resistant asymmetric algorithms (default: disabled)".

tested in conjunction with FIPS 20260508-wrapper-signature-harmony and WolfGuard 20260713-wc_AesGcmEncrypt_fips using

wolfssl-multi-test.sh ...
pr-check
check-source-text-fips-dev

quantum-safe-wolfssl-all-crypto-only-intelasm-fips-dev-linuxkm-next-insmod-gcc-latest
quantum-safe-wolfssl-all-crypto-only-noasm-fips-dev-linuxkm-next-clang-tidy
quantum-safe-wolfssl-all-crypto-only-intelasm-sp-asm-sp-linuxkm-next-insmod
quantum-safe-sanitizer-all-crypto-intelasm-c-fallback-fuzzer

fips-140-3-optest-acvp-defaults
fips-140-3-pilot-optest-acvp-sp-asm
fips-140-3-optest-acvp-defaults
fips-140-2-optest
fips-140-2-openssl-all
fips-140-2-wolfrand-defaults
fips-140-3-v5-ready-optest-acvp-intelasm
fips-140-3-v6-optest-acvp-sp-asm
fips-140-3-dev-optest-acvp-sp-asm-gcc-latest
fips-140-3-v6-optest-acvp-sp-asm
fips-140-3-optest-acvp-sp-asm
fips-140-3-dev-optest-acvp-sp-noasm
fips-140-3-all

linuxkm-defaults-all-fips-v6-sanitizer
linuxkm-defaults-all-quantum-safe-fips-dev-gcc-latest
linuxkm-defaults-all-fips-dev-sanitizer

cross-armv7a-armasm-fips-140-3-dev-sp-all-testsuite-sanitizer
cross-aarch64-armasm-fips-140-3-dev-all-unittest
cross-powerpc64-all-asm

defaults-cryptonly-Wconversion-intelasm-build
defaults-cryptonly-Wconversion-intelasm-fips-140-3-dev-build
allcryptonly-Wconversion-intelasm-build

linuxkm-benchmarks-asm-insmod
linuxkm-benchmarks-fips-insmod
linuxkm-fips-v6-dist-insmod-cust-kernel-2
linuxkm-fips-v5-strict-dist-insmod-cust-kernel-2-amdrdseed
linuxkm-fips-dev-dist-insmod-cust-kernel-2-amdrdseed
'.*cust-kernel-3.*'

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m4

  • FLASH: .rodata.CSWTCH.1 +8 B, .rodata.str1.1 +82 B (+0.0%, 200,744 B / 262,144 B, total: 77% used)

gcc-arm-cortex-m4-crypto-only

  • FLASH: .rodata.CSWTCH.1 +8 B, .rodata.str1.1 +82 B (+0.1%, 174,992 B / 262,144 B, total: 67% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .rodata +88 B, .text +64 B (+0.0%, 771,708 B / 1,048,576 B, total: 74% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .rodata.CSWTCH.1 +8 B, .rodata.str1.1 +82 B, .text +64 B (+0.1%, 213,140 B / 262,144 B, total: 81% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .rodata +88 B (+0.0%, 325,616 B / 1,048,576 B, total: 31% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .rodata.CSWTCH.1 +8 B, .rodata.str1.1 +82 B (+0.0%, 236,570 B / 262,144 B, total: 90% used)

gcc-arm-cortex-m7-pq

  • FLASH: .rodata +88 B (+0.0%, 280,464 B / 1,048,576 B, total: 27% used)

linuxkm-standard

  • Data: __patchable_function_entries -8 B (-0.0%, 48,592 B)

stm32-sim-stm32h753

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #10920

⚠️ The automated review timed out after 120 minutes and was terminated. Please retrigger the review manually or contact the Fenrir team.

@JacobBarthelmeh
JacobBarthelmeh requested review from wolfSSL-Fenrir-bot and removed request for wolfSSL-Fenrir-bot July 15, 2026 22:06
@douzzer

douzzer commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Retest this please
(tooling glitches)

@JacobBarthelmeh

Copy link
Copy Markdown
Contributor

Retest this please Jenkins. CAVP self test failed Unable to start agent

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #10920

Scan targets checked: linuxkm-bugs, linuxkm-src, wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src

No new issues found in the changed files. ✅

@douzzer

douzzer commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

retest this please

@JacobBarthelmeh

Copy link
Copy Markdown
Contributor

Needs fully reviewed for being allowed with FIPS use before merged.

ejohnstown
ejohnstown previously approved these changes Jul 16, 2026

@kaleb-himes kaleb-himes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are in discussions with the CSTL regarding this solution. The CSTL has concerns if we were to incorporate this solution in either of the upcoming submissions.

We are seeking a resolution to satisfy the CSTL and CMVP but I don't think it would be safe to merge this before we have resolved the CSTL's concerns.

EDIT: Discussed with Douzzer, I think we have a path forward. Dismissing this request for changes.

@kaleb-himes
kaleb-himes self-requested a review July 17, 2026 14:12
@douzzer
douzzer dismissed stale reviews from ejohnstown and JacobBarthelmeh via b8850e3 July 19, 2026 18:45
@douzzer
douzzer force-pushed the 20260713-WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED-etc branch from d8bfd27 to b8850e3 Compare July 19, 2026 18:45

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #10920

Scan targets checked: linuxkm-bugs, linuxkm-src, wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread linuxkm/lkcapi_aes_glue.c
@douzzer

douzzer commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Note the Jenkins CAVP self-test builds for fips-ready depend on the fix currently at the head of wolfssl/fips#402 .

@douzzer

douzzer commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Note the multi-test failure,

unrecognized macros used:
WOLFSSL_OCSP_SCREEN_RESPONDER

is a false positive due to a multi-test bug to be fixed Monday, and is firing on code in master.

Frauschi
Frauschi previously approved these changes Jul 20, 2026

@Frauschi Frauschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

lealem47
lealem47 previously approved these changes Jul 20, 2026

@lealem47 lealem47 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good redirect @douzzer

douzzer added 18 commits July 20, 2026 11:09
wolfssl/wolfcrypt/aes.h: if HAVE_FIPS && !WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED, make wc_AesGcmEncrypt() a WOLFSSL_LOCAL, and if !_WC_BUILDING_AES_C, add a WC_DEPRECATED() attribute to it.

wolfssl/wolfcrypt/wc_compat.h, wolfssl/wolfcrypt/include.am, .wolfssl_known_macro_extras: add wc_compat.h: when HAVE_FIPS and !WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED, shim wc_AesGcmEncrypt() to remap it to FIPS-allowed APIs.

wolfssl/wolfcrypt/types.h: at the end, #ifndef BUILDING_WOLFSSL, #include <wolfssl/wolfcrypt/wc_compat.h>, to assure transparent shimming of wc_AesGcmEncrypt() for all outside callers.

wolfcrypt/src/evp.c, wolfcrypt/src/hpke.c, wolfcrypt/src/pkcs7.c, wolfcrypt/benchmark/benchmark.c, wolfcrypt/test/test.c, wolfssl/ssl.h: #include <wolfssl/wolfcrypt/wc_compat.h> to shim in-library/in-module calls to wc_AesGcmEncrypt().

src/internal.c: in TicketEncDec(), add const attributes to constable input args, and fix swapped out/in in calls to wc_AesGcmEncrypt().

tests/api/test_aes.c: in test_wc_AesGcmEncryptDecrypt(), skip longIV test if WC_TEST_AES_GCM_ENCRYPT_NO_NONSTD_IV (defined by wc_compat.h when needed).

wolfssl/wolfcrypt/error-crypt.h, wolfssl/error-ssl.h, wolfcrypt/src/error.c, src/internal.c:
* add FIPS_WRONG_API_E;
* put several error codes back into sequence in wc_GetErrorString() switch().
* move wc_static_assert()s from headers to corresponding .c files, to eliminate dependency on wolfcrypt/types.h;
* remove unneeded #include <wolfssl/wolfcrypt/types.h> from error-crypt.h.
…nd AES-XTS (AesGcmCrypt_1(), km_AesXtsEncrypt(), and km_AesXtsDecrypt()), bypass FIPS wrappers to avoid frivolous overhead, with decisive check after looping by the Final function.
…I, and intel_flags (3f3ebca / wolfSSL#10871) to avoid frivolous atomic access overhead.  Also use regular int, not cpuid_flags_atomic_t, for cpuid_flags in the WOLFSSL_ARMASM path, and similarly use a regular int for aes_ppc64_use_crypto in the WOLFSSL_PPC64_ASM_CRYPTO path.
…l_known_macro_extras:

* also inhibit recursive evaluation midway through random.h, fips.h, and fips_test.h (circular dependencies).
* add WC_FIPS_ENUM_CAST_ID_DEFINED to allow detection of fips_test.h incomplete evaluation.
* add missing null key checks to wc_ed25519_verify_msg_init(), wc_ed25519_verify_msg_update(), and wc_ed25519_verify_msg_final().
* add WC_ARG_NOT_NULL() attributes to args of static functions as appropriate.
* add FIPS >v6 gates to new null key tests and a new invalid hash size test in test_wc_ed25519_sign_verify_ctx_ph() and test_wc_ed25519_verify_streaming().
…istant asymmetric algorithms (default: disabled)".
…h> where previously #include <wolfssl/wolfcrypt/types.h>, to retain standalone compilability without provoking circular dependencies via wc_compat.h.
…at_shim(), restore aes->reg to the supplied IV after wc_AesGcmEncrypt_ex() increments it, supporting the EVP access pattern.
…_EXT_IV_ALLOWED isn't defined in old FIPS builds.
…ash", for the hash type in wc_PRF_fips(), for clarity and consistency.
…or-crypt.h, wolfcrypt/src/error.c:

* Fix vector register restore on error paths in Sha3Update().

* Add SP 800-185 check against KMAC_FIPS_MIN_KEY in KmacInit() and
  KMAC_FIPS_MIN_OUTPUT in KmacFinal(), returning KMAC_MIN_KEYLEN_E and
  BAD_LENGTH_E respectively on failure.

* Use word32 rather than byte for wc_Sha3.i, wc_Cshake.count, wc_Kmac.count, and
  related, and add explicit range checking where needed, to fix a -Wconversion,
  fix possible overruns, obviate 14 casts, and eliminate (negligible) runtime
  overhead from masking and promotions.
@douzzer
douzzer dismissed stale reviews from lealem47 and Frauschi via 3f9bc8c July 20, 2026 16:10
@douzzer
douzzer force-pushed the 20260713-WC_FIPS_AESGCM_ONE_SHOT_EXT_IV_ALLOWED-etc branch from b05470c to 3f9bc8c Compare July 20, 2026 16:10
@douzzer

douzzer commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Only remaining CI failures are fips-ready due to missing !NO_DH gates in harness/cavp_dh.c and harness/cavp_common.h, fixed by wolfssl/fips#402.

@JacobBarthelmeh
JacobBarthelmeh merged commit 39a6073 into wolfSSL:master Jul 20, 2026
342 of 345 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants